package org.apache.ibatis.test_clxmm.test04_pluging.plug;

import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;

import java.util.Arrays;

@Intercepts(@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}))
public class CustomInterceptor implements Interceptor {
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
    System.out.println("CustomInterceptor intercept run ......");
    // 顺便，把这个Invocation中的东西也打印出来吧
    System.out.println(invocation.getTarget());
    System.out.println(invocation.getMethod().getName());
    System.out.println(Arrays.toString(invocation.getArgs()));
    return invocation.proceed();
  }
}
